package com.qiankunxu.listener;

import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

/**
 * @author : Hunter Huang
 * @since : 2023/12/14 20:20
 * {@literal : some description}
 */
public class MyListener implements ApplicationListener {
    @Override
    public void onApplicationEvent(ApplicationEvent event) {
        //对应两个事件: ApplicationReadyEvent   ApplicationFailedEvent
        if(event instanceof ApplicationReadyEvent){
            //容器初始化成功事件
            System.out.println("MyListener...容器初始化成功...");
        }

        if(event instanceof ApplicationFailedEvent){
            //容器初始化失败事件
            System.out.println("MyListener...容器初始化失败...");
        }
    }
}
